package blog.controller;

import blog.entity.Document;
import blog.entity.Report;
import blog.entity.Tag;
import blog.service.back.ReportBackService;
import blog.util.back.ControllerUtil;
import blog.vo.back.ByReportStatusGetAllReportInfoVO;
import blog.vo.back.ByReportUuidAndBlogUuidGetReportInfoVO;
import blog.vo.back.ReportVO;
import blog.vo.back.UpdateReportStatusVO;
import blog.vo.common.PaginationVO;
import blog.vo.common.ResponseListObjectVO;
import blog.vo.common.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 　　* @description: TODO
 * 　　* @param
 * 　　* @return
 * 　　* @throws
 * 　　* @author Administrator
 * 　　* @date $ $
 *
 */
@Controller
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ReportBackService reportBackService;

    @RequestMapping("/get-all-reportInfo")
    private String getAllReportInfo(PaginationVO paginationVO, Model model){
        List<ReportVO> allReportInfo = reportBackService.getAllReportInfo(paginationVO);
        model.addAttribute("allReportInfo",new ResponseListObjectVO<ReportVO>(200,"ok",allReportInfo).getResponseObject());
        return "home";
    }

    @PostMapping("/by-report-status-get-all-reportInfo")
    private String byReportStatusGetAllReportInfo(ByReportStatusGetAllReportInfoVO byReportStatusGetAllReportInfoVO, Model model){
        List<ReportVO> allReportInfo = reportBackService.byReportStatusGetAllReportInfo(byReportStatusGetAllReportInfoVO);
        model.addAttribute("allReportInfo",new ResponseListObjectVO<ReportVO>(200,"ok",allReportInfo).getResponseObject());
        return "home";
    }

    @RequestMapping("/by-report-uuid-and-blog-uuid-get-reportInfo")
    public String byReportUuidAndBlogUuidGetReportInfo(ByReportUuidAndBlogUuidGetReportInfoVO byReportUuidAndBlogUuidGetReportInfoVO,Model model){
        Report report = reportBackService.byReportUuidAndBlogUuidGetReportInfo(byReportUuidAndBlogUuidGetReportInfoVO);
        model.addAttribute("report",new ResponseVO<Report>(200,"ok",report).getResponseObject());
        return "common-data";
    }

    @PostMapping("/update-report-status")
    private String updateReportStatus(UpdateReportStatusVO updateReportStatusVO,Model model){
        int result = reportBackService.updateReportStatus(updateReportStatusVO);
        String updateResultUrl = ControllerUtil.updateResultUrl(result, "redirect:/report/get-all-reportInfo", model);
        return updateResultUrl;
    }
}
